//app.js
const quote = require('utils/quoteConfig.js') //统一引入文件
const Recorder = quote.Recorder //引入外部录音接口
const api = quote.api;
// const aldstat = quote.aldstat;
const mta = quote.mta;
const tools = quote.tools;
// const DataStorage = quote.DataStorage;
const WXlogin = quote.WXlogin;
const Statistics = quote.Statistics;

App({

    onLaunch: function(options) {
        let that = this

        console.log('app onLaunch,第一次加载小程序获取到的数据', options);

        new WXlogin(this, api); //微信登录获取用户openId

        Statistics(options, that, mta) //小程序数据统计

        tools.writeDefaultData(that); //小程序如果是当天第一次打开往缓存里面写入一个默认练习次数

    },
    onShow: function(options) {
        let that = this;

        console.log('app onShow,进入小程序获取到的数据', options);

    },
    onHide: function() {
        let that = this;
        console.log('app onHide,小程序隐藏了');

        //发送formId到后台
        tools.sendFormId(that)

    },
    onError: function(msg) {
        console.log(msg)
    },
    globalData: {
        ADisPop: false, //广告是否已经弹出
        AlreadyPracticed: {}, //已经练习过的视频列表
        DefaultTimes: 0, //每日挑战的默认练习次数
        AccountsTimes: 0, //账户中获取的练习次数
        SDKVersion: null,
        userInfo: null,
        certificationOk: 0, //是否认证
        appId: 'wx820493357a58f254', //微信小程序的appId
        appSecret: '5a6ec00b69f935b4453934a73e5de1c2', //微信小程序的密钥
        appkey: '049BD15C6FC04BD80808A601DC46E50515CBEEA33FB29AB4',
        appSource: "MiniappTTKYX_578009", //渠道来源
        wxCode: null,
        session_key: null, //会话密钥
        UID: 420683, //微信中用户唯一标识符
        openId: null, //小程序中用户唯一标志符o_f4J0RLl9LpHOc1Ra_Q3gvAkoLo
        loginStatus: false, //登录状态
        videoUrl: "https://video.acadsoc.com.cn",
        apiUrl: "https://ies.acadsoc.com.cn",
        baseAshx: "/ECI/WeChatSmallProgram/WeChat_Base.ashx", //域名虚拟路径
        mediaUrl: "https://admin.acadsoc.com.cn", //图片及录音地址
        //  videoUrl: "http://192.168.74.98:8085", //测试视频地址"http://192.168.74.98:8085"
        // apiUrl: "http://192.168.74.224:8085", //测试api地址"http://192.168.74.189:8000"
        timer: 30000, //定时器设置时间
        access_token: null, //访问令牌
        recorder: new Recorder('1510645856000042', '412ab8c468fcd728c584990850d3a77d'), //创建一个 Recorder 对象
        innerAudioContext: wx.createInnerAudioContext(), //创建一个音频播放器
        videoCacheObj: {},
        redPaperIsOpened: null,
        quote: quote
    }
})